#ifndef _PROTOCOL_H_
#define _PROTOCOL_H_


#include <stdint.h>

typedef void (*protocol_callback_function)(uint8_t*, uint32_t);
typedef void (*cmd_callback_function)(uint8_t*, uint32_t);

#define PT_HEAD_H 0X55
#define PT_HEAD_L 0X7A
#define PT_VERSION 0X02

#define PT_HEAD_POS 0
#define PT_VER_POS 2
#define PT_NUM_POS 3
#define PT_CMD_POS 4
#define PT_TIMESTAMP_POS 5
#define PT_DEVICE_TYPE_POS 13
#define PT_DEVICE_SN_POS 14
#define PT_DATA_LEN_POS 26
#define PT_DATA_POS 28

#define PROTOCOL_COMM_FAIL 1
#define PROTOCOL_COMM_SUCESS 0
#define PROTOCOL_CMD_NULL	0X00
#define PROTOCOL_CMD_INDEX_NULL 0XFF

enum{
	ROTOCOL_CMD_UNKOWN = 0X00,
	PROTOCOL_CMD_0X04 = 0X04,
	PROTOCOL_CMD_0X05,
	PROTOCOL_CMD_0X06,
	PROTOCOL_CMD_0X07,
	PROTOCOL_CMD_0X08,
	PROTOCOL_CMD_0X09,
	PROTOCOL_CMD_0X0A,
};

uint8_t protocol_pack_check(uint8_t* data,uint16_t len);
uint8_t protocol_pack_buf_init(protocol_callback_function ippcf, protocol_callback_function vppcf, protocol_callback_function ppsf);
uint8_t protocol_register_cmd(uint8_t cmd, cmd_callback_function ccf, uint8_t mode);
uint8_t protocol_pack_add(uint8_t cmd,uint8_t* data,uint16_t len,uint8_t repeats);
uint8_t protocol_receive_process(uint8_t* data,uint16_t len);
uint8_t protocol_polling_send(void);


#endif


